package com.persistence;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

@Entity
@Table(name="t_player")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name="reserve", discriminatorType=DiscriminatorType.INTEGER)
public abstract class TPlayer implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private Integer idPlayer;
	private String firstname;
	private String lastname;
//	private Integer idTeam;
//	private Integer idPhoto;
	private TPhoto TPhoto;
	private Date joinDate;
//	private Integer reserve;
	private TFootballTeam TFootballTeam;
	
	@Id
	
	@Column(name="id_player", unique=true, nullable=false)
	public Integer getIdPlayer() {
		return idPlayer;
	}
	public void setIdPlayer(Integer idPlayer) {
		this.idPlayer = idPlayer;
	}
	
	@Column(name="firstname", nullable=false)
	public String getFirstname() {
		return firstname;
	}
	public void setFirstname(String firstname) {
		this.firstname = firstname;
	}
	
	@Column(name="lastname", nullable=false)
	public String getLastname() {
		return lastname;
	}
	public void setLastname(String lastname) {
		this.lastname = lastname;
	}
	
//	@Column(name="photo_id")
//	public Integer getIdPhoto() {
//		return idPhoto;
//	}
//	public void setIdPhoto(Integer idPhoto) {
//		this.idPhoto = idPhoto;
//	}
	
	@Temporal(TemporalType.DATE)
	@Column(name="join_date")
	public Date getJoinDate() {
		return joinDate;
	}
	public void setJoinDate(Date joinDate) {
		this.joinDate = joinDate;
	}
	
//	@Column(name="reserve")
//	public Integer getReserve() {
//		return reserve;
//	}
//	public void setReserve(Integer reserve) {
//		this.reserve = reserve;
//	}
	
	@ManyToOne
	@JoinColumn(name="team_id", nullable=true)
	public TFootballTeam getTFootballTeam() {
		return TFootballTeam;
	}
	public void setTFootballTeam(TFootballTeam tFootballTeam) {
		TFootballTeam = tFootballTeam;
	}
	
	@OneToOne(fetch=FetchType.EAGER, cascade = CascadeType.ALL)
	@JoinColumn(name="photo_id")
	public TPhoto getTPhoto() {
		return this.TPhoto;
	}

	public void setTPhoto(TPhoto TPhoto) {
		this.TPhoto = TPhoto;
	}
	
}
